<template>
  <div class="p20 bg-white console">
    <el-form
      :model="form"
      ref="form"
      class="form-align-center mt20 overflow pl15 pr15"
      label-position="right"
    >
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="所属部门：" prop="departmentId" :label-width="labelWidth">
            <span>{{form.deptName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="所属岗位：" prop="jobId" :label-width="labelWidth">
            <span>{{form.jobName}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="员工姓名：" prop="realName" :label-width="labelWidth">
            <span>{{form.realName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="手机号码：" prop="phone" :label-width="labelWidth">
            <span>{{form.phone}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="身份证号码：" prop="idCard" :label-width="labelWidth">
            <span>{{form.idCard}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="性别：" prop="sex" :label-width="labelWidth">
            <span>{{form.sex}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="职业证件类型：" prop="professionalDocumentType" :label-width="labelWidth">
            <span>{{form.professionalDocument?form.professionalDocument:'--'}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="职业证件号码：" prop="professionalDocumentCode" :label-width="labelWidth">
            <span>{{form.professionalDocumentCode?form.professionalDocumentCode:'--'}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="职称等级：" prop="titleLevelType" :label-width="labelWidth">
            <span>{{form.titleLevel?form.titleLevel:'--'}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="学历：" prop="educationType" :label-width="labelWidth">
            <span>{{form.education}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around">
        <el-col :span="9" class="mb15">
          <el-form-item label="入职日期：" prop="joinDate" :label-width="labelWidth">
            <span>{{form.joinDate}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="9" class="mb15">
          <el-form-item label="员工照片：" prop="educationType" :label-width="labelWidth">
            <img class="detail-photo" :src="form.photo" @click="handleShowPic(form.photo)" alt />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="space-around" class="mt20 pt20">
        <el-col :span="12" class="mb15">
          <el-form-item>
            <el-button style="width: 120px;" class="theme-btn" @click="handleEdit">修改资料</el-button>
            <GoBack />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <PhotoDialog @showPic="handleShowPic" :showPic="showPic" :isShowPic="isShowPic"></PhotoDialog>
  </div>
</template>

<script>
import GoBack from "@/components/go_back";
import { getInnerUser } from "@/apis/user";
import PhotoDialog from "@/components/photo_dialog";

export default {
  name: "Detail_user",
  data() {
    return {
      form: {
        phone: "",
        idCard: "",
        jobName: "",
        realName: "",
        joinDate: "",
        education: "",
        titleLevel: "",
        departmentName: "",
        professionalDocument: "",
        professionalDocumentCode: ""
      },
      jobList: [],
      showPic: "",
      fileList: [],
      deptList: [],
      isShowPic: false,
      dialogImageUrl: "",
      labelWidth: "110px",
      dialogVisible: false,
      educationTypeList: [],
      titleLevelTypeList: [],
      professionalDocumentTypeList: []
    };
  },
  created() {
    this.getDetailUser();
  },
  methods: {
    async getDetailUser() {
      const { object } = await getInnerUser({
        internalUserId: this.$route.query.id
      });

      this.form = object;
    },
    handleShowPic(data) {
      this.showPic = data;
      this.isShowPic = !this.isShowPic;
    },
    handleEdit(id) {
      this.$router.push({
        name: "editUser",
        query: {
          id: this.form.id
        }
      });
    }
  },
  components: {
    GoBack,
    PhotoDialog
  }
};
</script>

<style scoped lang="less">
</style>
